<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <div id="app">
        <form action="https://www.baidu.com/s">
            <input name="wd" type="text">
        </form>

    </div>
    <div id="root"></div>
</body>
<script>
    // https://www.baidu.com/sugrec?prod=pc&wd=大连海洋&cb=fn
    // 获取 id 为app元素包裹的第一个input标签元素
    const appInp = document.querySelector("#app input");
	function fn({g=[]}){
		console.log(g);
		document.querySelector("#root").innerHTML = g.map(item=>(`
		    <p>${item.q}</p>
		`)).join("")
    }
	appInp.oninput = function(){
		const script = document.createElement("script");
		script.src = `https://www.baidu.com/sugrec?prod=pc&wd=${this.value}&cb=fn`;
		document.body.appendChild(script);
		document.body.removeChild(script);
    }

</script>
</html>